package ProblemaOptimizacion;

public class Funcion {

	public static double f1 (double x){
		double num = Math.sin(x);
		double den = 1 + Math.sqrt(x) + Math.cos(x)/(1+x);
		return num/den;
	}
	
	public static double f2 (double x, double y){
		double num = 2186 - Math.pow((Math.pow(x, 2) + y - 11),2) - Math.pow((x + Math.pow(y, 2) - 7),2);
		double den = 2186;
		return num/den;
	}
	
	public static double f3 (double x,double y){
		return 21.5 + x*Math.sin(4*Math.PI*x) + y*Math.sin(20*Math.PI*y);
	}
	
	public static double f4(double[] x, int n){
		double res = 0.0;
		for(int i = 0;i<n;i++){
			double v1 = Math.sin(x[i]);
			double v2 = (i + 3)*Math.pow(x[i], 2)/Math.PI;
			res = res + v1*Math.pow(Math.sin(v2), 20);
		}
		return -1*res;
	}
	
	public static double f5(double[] x){
		double valor1 = 0.0;
		double valor2 = 0.0;
		for (int i=1;i<=5;i++){
			valor1 = valor1 + i*Math.cos((i+1)*x[0] + i);
		}
		for (int j=1;j<=5;j++){
			valor2 = valor2 + j*Math.cos((j+1)*x[1] + j);
		}
		return valor1*valor2;
	}
}
